<?php

namespace App\Http\Models;

class GoodsAudit extends BaseModel
{
    protected $table = 'goods_audit';
    protected $guarded = [];

    public static function addLog($goodsid, $admin_id, $status, $content = '')
    {
        $goods_info = Goods::find($goodsid);
        $data = [
            'admin_id' => $admin_id,
            'gid' => $goodsid,
            'user_id' => $goods_info->userid,
            'title' => $goods_info->goodstitle,
            'state' => $status,
            'content' => $content,
            'goodstype' => $goods_info->goodstype,
        ];
        return self::create($data);
    }

    public static function KilladdLog($killid, $admin_id, $status)
    {
        $kill = GoodsKill::find($killid);
        return self::addLog($kill->gid, $admin_id, $status);
    }

    //对应商品表
    public function goods()
    {
        return $this->belongsTo(Goods::class, 'gid');
    }
}